<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">

<head>
<title>js第2课-if判断-显示隐藏</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="这是js第2课-if判断-显示隐藏">
<style type="text/css">
#div1 {
	width: 100px;
	height: 200px;
	background: pink;
	display: none;
}
</style>
<script type="text/javascript">
	function showHide() {
		var div1 = document.getElementById('div1');
		if (div1.style.display == "block") {
			div1.style.display = "none";
		} else {
			div1.style.display = "block";
		}

	}
</script>
</head>

<body>
	<input type="button" value="显示隐藏" onclick="showHide()">
	<div id="div1"></div>
</body>

</html>